//
//  AppDelegate.m
//  OpenGL_ES_Demo
//
//  Created by Wang Shuguang on 12-12-24.
//  Copyright (c) 2012年 elong. All rights reserved.
//

#import "AppDelegate.h"
#import "RootViewController.h"

@implementation AppDelegate


- (void)dealloc
{

    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.

    
    rootVC = [[RootViewController alloc] init];
     
    self.window.rootViewController = rootVC;
    [rootVC release];

    self.window.backgroundColor = [UIColor whiteColor];
    
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    
    
    [rootVC stopMotionListen];
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [rootVC stopMotionListen];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    [rootVC startMotionListen];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    //self.glView.animationInterval = 1.0 / 60.0;
    
    [rootVC startMotionListen];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    [rootVC stopMotionListen];
}

@end
